<?php
/*
* Kusht Mud.
* ----
* The MIT License
* Copyright (c) 2010 Andrew Tutt
* ----
*/

/* Room Class
*
* This is the Game Object for a Room
*/

require_once "BaseObject.class.inc";

class Room extends BaseObject {
	public $people		= array();  		// UserCharacters in the Room
	public $contents 	= array();			// Objects in the Room
	public $extra_descr; 					// ExtraDescription (a future struct)
	public $area;							// The Area in Which the Room is Embedded
	public $exits		= array();			// Array of Exit Objects (unlimited)
	
	// ints all
	public $vnum;
	public $room_flags;
	public $light;
	public $sector_type;
	
	function get_char_room($queryinguser, $targetstr) {
		foreach($this->people as $person) {
			if (stripos($person->name,$targetstr)!==FALSE) { return $person; }
		}
		
		return FALSE;
	}
	
	function add_char_to_room($user) {
		array_push($this->people,$user);
		$this->roomUpdate();
	}
	
	function rmv_char_from_room($user) {
		array_del_elem($this->people,$user);
		$this->roomUpdate();
	}
	
	function roomUpdate() {
		// Who cares about what happens in a room? Only those watching it.
		// For now, let's limit that to only those people in it
		foreach($this->people as $person) {
			$person->change("in_room",$this);
		}
	}
}

?>